NexusPi Git Node
native/reboot.h HEAD (592c826d) Text, 1.61 KB
T8b949e// Copyright (C) 2026, Chad Attermann
T8b949e//
T8b949e// Deferred-reboot mechanism for the native daemon. Mirrors embedded
T8b949e// firmware's hard_reset() semantics: a KISS-driven config write (e.g.
T8b949e// drot_conf_save, dia_conf_save, eeprom_erase) or an explicit CMD_RESET
T8b949e// signals that the daemon should re-initialize from the updated EEPROM.
T8b949e//
T8b949e// On ESP32/NRF52 this is `ESP.restart()` / `NVIC_SystemReset()` — a hard
T8b949e// reset of the MCU. On native, we mirror meshtasticd's pattern: schedule
T8b949e// the reboot via a flag, let the current loop tick finish (so any pending
T8b949e// KISS ACK can flush), then tear down host-side resources and call
T8b949e// Portduino's `reboot()`, which execv()s argv[0]. The process image is
T8b949e// replaced; portduinoSetup() and setup() run fresh.
Tff7b72#Tff7b72ifndef NATIVE_REBOOT_H
Tff7b72#Tff7b72define NATIVE_REBOOT_H
Te6edf3namespace Te6edf3native_reboot Tb4b4b4{
T8b949e// Set the deferred-reboot flag. Idempotent; safe to call from any
T8b949e// hard_reset() call site.
Tffa657void Td2a8ffrequestTb4b4b4(Tb4b4b4)Tb4b4b4;
T8b949e// True if a reboot has been requested but not yet performed. Checked at
T8b949e// the top of the firmware's loop().
Tffa657bool Td2a8ffpendingTb4b4b4(Tb4b4b4)Tb4b4b4;
T8b949e// Tear down host-side resources (KISS-TCP listener + client, libgpiod
T8b949e// handles, SPI) and execv() argv[0]. Does not return.
Tb4b4b4[Tb4b4b4[Tff7b72noreturnTb4b4b4]Tb4b4b4] Tffa657void Te6edf3performTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4} T8b949e// namespace native_reboot
T8b949e// File-scope shims used by Utilities.h::hard_reset() and the .ino loop()
T8b949e// to avoid pulling this header (under native/) into the global include
T8b949e// path of the rest of the firmware. Each just delegates to the namespaced
T8b949e// API above.
Tffa657void Te6edf3native_request_rebootTb4b4b4(Tb4b4b4)Tb4b4b4;
Tffa657bool Td2a8ffnative_reboot_pendingTb4b4b4(Tb4b4b4)Tb4b4b4;
Tb4b4b4[Tb4b4b4[Tff7b72noreturnTb4b4b4]Tb4b4b4] Tffa657void Te6edf3native_reboot_performTb4b4b4(Tb4b4b4)Tb4b4b4;
Tff7b72#Tff7b72endif T8b949e// NATIVE_REBOOT_H
Served by rngit 1.5.2 - Generated in 0.01s